package com.dkd.manage.mapper;

import com.dkd.manage.annotation.AutoFill;
import com.dkd.manage.constant.OperationType;
import com.dkd.manage.pojo.entity.Sku;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SkuMapper {


    /**
     * 分页查询商品列表
     * @param skuName
     * @return
     */
    List<Sku> list(String skuName);


    /**
     * 新增商品
     * @param sku
     * @return
     */
    @AutoFill(OperationType.INSERT)
    Integer add(Sku sku);

    /**
     * 修改商品
     * @param sku
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    Integer edit(Sku sku);

    /**
     * 根据id删除商品
     * @param ids
     * @return
     */
    Integer deleteSkuById(@Param("ids") Long[] ids);

    /**
     * 根据id查询商品
     * @param id
     * @return
     */
    @Select("select sku_id, sku_name, sku_image, brand_Name, unit, price, class_id, is_discount, " +
            "create_time, update_time, create_by, update_by from tb_sku where sku_id = #{id}")
    Sku getSkuById(Long id);

}
